package org.vnl.platform.service.rule;

import java.text.DecimalFormat;

import org.vnl.platform.dk.util.SEVERITY;

/**
 * 規則執行時可能會拋出的錯誤代碼
 * 
 * @author Vaughan
 *
 */
public enum RuleErrCode {

    LOAD_RULE_CONFIG_ERR(SEVERITY.EXCEPTION),
    INCOMPATIBLE_RULE_CONFIG_CONTAINER(SEVERITY.EXCEPTION);
    
    SEVERITY severity;
    
    private RuleErrCode(SEVERITY severity) {
        this.severity = severity;
    }
    
    @Override
    public String toString() {
        StringBuffer sb = new StringBuffer();
        sb.append("RL_");
        DecimalFormat df = new DecimalFormat("0000");
        sb.append(df.format(this.ordinal()));
        return sb.toString();
    }

    public String getSeverityString() {
        return this.severity.toString();
    }
    
    public SEVERITY getSeverity() {
        return this.severity;
    }
    
    public static void main(String[] args) throws Exception {
        RuleErrCode[] codes = RuleErrCode.values();
        for (int ii = 0; ii < codes.length; ii++) {
            System.out.println("#" + codes[ii].name());
            System.out.println(codes[ii].toString() + "=\n");
        }
    }
}
